//
//  ViewController.m
//  ExcelParse
//
//  Created by 朱志佳 on 2019/7/18.
//  Copyright © 2019 朱志佳. All rights reserved.
//

#import "ViewController.h"
#import "QuickExcelReaderUtil.h"
#import "CSVParser.h"
#import "ZHeader.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)csvParse:(id)sender {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"test.csv" ofType:nil];
    NSMutableArray *arrayM = [CSVParser readCSVData:path];
    NSLog(@"csvParse:%@",arrayM);
}

- (IBAction)xlsxParse:(id)sender {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"test2.xlsx" ofType:nil];
    [QuickExcelReaderUtil readExcelWithPath:path complete:^(NSDictionary<NSString *,NSArray<ZContent *> *> *results, NSError *error) {
        NSLog(@"xlsxParse:");
        for (NSString *key in results) {
            NSArray *contents = results[key];
            for (ZContent *content in contents) {
                if ([content isKindOfClass:ZContent.class]) {
                    if (IsEmptyOrNull(content.value)) {
                        continue;
                    }
                    NSLog(@"%@:%@",content.keyName, content.value);
                }else {
                    NSLog(@"content is not ZContent");
                }
            }
        }
    }];
}


@end
